package com.hq.commons.utils;


import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;

public class GsonUtils {


    public static String toJSON(Object object) {
        return JSON.toJSONString(object);

    }

    public static <T> T toObject(String data, Class<T> tClass) {
        return JSON.parseObject(data, tClass);
    }

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("A");
        list.add("b");
        list.add("c");
        String json = GsonUtils.toJSON(list);
        System.out.println(json);
        List<String> stringList = (List<String>) GsonUtils.toObject(json, List.class);
        System.out.println(stringList);
    }
}
